<template>
  <div id="app">
    <ul>
      <li v-for="(item,index) in arr" :key="index">
        <span>{{item}}</span>
        <button @click="shan(index)">删除</button>
      </li>
    </ul>
    <button @click="shen">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
    };
  },
  methods: {
    shen(){
      this.arr.push(parseInt(Math.random()*20))
      console.log(parseInt(Math.random()*20));
    },
    shan(index){
this.arr.splice(index,1)
    }
  },
}
</script>